//
//  JQFXHNetworkError.swift
//  jiuzhoudai
//
//  Created by zhaochengfeng on 2025/7/9.
//

import Foundation

enum JQFXHNetworkError: Error, LocalizedError {
    case invalidURL
    case businessError(code: Int, message: String)
    case httpError(statusCode: Int)
    case headError
    case tokenExpired
    case decodingError
    case unauthorized
    case methodError
    case serverError
    case unknown
    
    var errorDescription: String? {
        switch self {
        case .invalidURL:
            return "无效的请求地址"
        case .decodingError:
            return "数据解析失败"
        case .businessError(_, let message):
            return message
        case .httpError(let statusCode):
            return "请求失败，状态码：\(statusCode)"
        case .headError:
            return "请求头错误"
        case .methodError:
            return "请求方法错误"
        case .serverError:
            return "服务器内部错误"
        case .tokenExpired:
            return "登录过期，请重新登录"
        case .unauthorized:
            return "登录过期，请重新登录"
        case .unknown:
            return "未知错误"
        }
    }
}
